import React, {useState,useEffect} from 'react';
import { UserOutlined } from '@ant-design/icons';
import { Menu,Avatar } from 'antd';
import {inject, observer} from "mobx-react";
import {Link} from "react-router-dom";
import './LeftMenu.css'


function LeftMenu(props)  {
    const juri=props.user.routerurl
    const [data,setData]=useState()
    const [user,setUser]=useState(props.user.user[0].userName)
    const Jurip=()=> {
        let arr=[]
        let keuId=1;
        juri.forEach((item,key)=>{
            if(item.Id>3) {
                arr.push(<Menu.Item key={keuId}><Link to={item.routerUrl}>{item.routerName}</Link></Menu.Item>)
                keuId++
            }
        })
        arr.push(<Menu.Item key={keuId}><Link to={'/login'}>退出系统</Link></Menu.Item>)
        setData(arr)
    }
    useEffect(()=>{
        Jurip();
    },[])
    return (
        <div>
            <div className={"touxiang"}>
                <Avatar size={64} icon={<UserOutlined />} />
                <p>{user},欢迎您</p>
            </div>
            <Menu
                mode="inline"
                defaultSelectedKeys={['']}
                defaultOpenKeys={['sub1']}
                style={{ height: '100%', borderRight: 0 }}
            >
                {data}
                {/*<Menu.Item key="1"><Link to={'/index/commodityset'}>商品基础设置</Link></Menu.Item>*/}
                {/*<Menu.Item key="2"><Link to={'/index/storeset'}>门店基础设置</Link></Menu.Item>*/}
                {/*<Menu.Item key="3"><Link to={'/index/staffset'}>员工基础设置</Link></Menu.Item>*/}
                {/*<Menu.Item key="4"><Link to={'/index/suppierset'}>供应商基础设置</Link></Menu.Item>*/}
                {/*<Menu.Item key="5"><Link to={'/index/juri'}>权限管理</Link></Menu.Item>*/}
                {/*<Menu.Item key="6"><Link to={'/index/systemset'}>系统设置</Link></Menu.Item>*/}
                {/*<Menu.Item key="7"><Link to={'/index/xgmm'}>更改密码</Link></Menu.Item>*/}
                {/*<Menu.Item key="8"><Link to={'/login'}>退出系统</Link></Menu.Item>*/}
            </Menu>
        </div>
    );

}

export default inject('user')(observer(LeftMenu));